package org.csu.group4.jpetstore.config;

import org.csu.group4.jpetstore.interceptor.MyInterceptor;
import org.csu.group4.jpetstore.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/account/**")
                .excludePathPatterns("/admin/**")
                .excludePathPatterns(
                        "/static/**",

                        "/catalog/main",
                        "/catalog/product/**",
                        "/catalog/productId/**",
                        "/catalog/itemId/**",
                        "/catalog/item/**",
                        "/catalog/search/**",
                        "/",
                        "/help"
                        );
        registry.addInterceptor(new AdminInterceptor())
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/token");
    }

}
